from utils.base_response_code import BaseResponseCode
from rest_framework.response import Response
from typing import Union, Optional


class BaseResponse(Response):
    def __init__(self, code: BaseResponseCode, msg: str, data: Optional[Union[dict, list]] = None, **kwargs):
        if data is None:
            data = {}
        response_data = {
            "code": code.value,
            "msg": msg,
            "data": data
        }
        super().__init__(data=response_data, status=200, **kwargs)
